home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1998 July / EnigmA AMIGA RUN 29 (1998)(G.R. Edizioni)(IT)[!][issue 1998-07 & 08].iso / earkit / news / thor / rexx / pgpdecrypt.thor < prev    next >
Text File  |  1998-05-24  |  2KB  |  115 lines

  1. /* $VER: PGPDecrypt.thor 3.3 (21.2.95)
  2.  *
  3.  * Arexx script to decrypt PGP messages. When executed will the current message
  4.  * in Thor be fed to PGP. The decrypted message will be put into the message 
  5.  * listview where it can be viewed and replied.
  6.  *
  7.  * Script by: Eivind Nordseth, Ultima Thule Software.
  8.  */
  9.  
  10. /* trace results */
  11.  
  12. options results
  13.  
  14. p = ' ' || address() || ' ' || show('P',,)
  15. thorport = pos(' THOR.',p)
  16.  
  17. if thorport > 0 then thorport = word(substr(p,thorport+1),1)
  18. else
  19. do
  20.     say 'No THOR port found!'
  21.     exit 10
  22. end
  23.  
  24. if ~show('p', 'BBSREAD') then do
  25.     address command
  26.         "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
  27.         "WaitForPort BBSREAD"
  28. end
  29.  
  30. filename = 't:pgptext'
  31. outfile  = 't:pgpout'
  32.  
  33. address command 
  34. if exists(filename) then 'delete >nil:' filename
  35. if exists(outfile)  then 'delete >nil:' outfile
  36.  
  37. address(thorport)
  38. SAVEMESSAGE CURRENT FILE filename NOHEADER
  39. if(rc ~= 0) then 
  40. do 
  41.     REQUESTNOTIFY TEXT '"Not able to save current message."' BT '"_Ok"'
  42.     exit
  43. end
  44.  
  45. address command 'search >nil:' filename '"BEGIN PGP MESSAGE" QUICK QUIET' 
  46. if(rc = 5) then
  47. do
  48.     address command 'search >nil:' filename '"BEGIN PGP SIGNED MESSAGE" QUICK QUIET' 
  49.     if(rc = 5) then
  50.     do
  51.         REQUESTNOTIFY TEXT '"This is not a PGP encrypted or signed message"' BT '"_Ok"'
  52.         exit
  53.     end
  54. end
  55.  
  56. if(rc ~= 0) then
  57. do
  58.     REQUESTNOTIFY TEXT '"Search failed. Check path."' BT '"_Ok"'
  59.     exit
  60. end
  61.  
  62. GETGLOBALCONFIG CFG
  63. if(rc ~= 0) then exit
  64.  
  65. address BBSREAD GETGLOBALDATA stem GLOBALDATA
  66. if(rc ~= 0) then exit
  67.  
  68. Call Close 'STDOUT'          
  69. Call Close 'STDIN'
  70. Call Open 'STDOUT','CON:0/13//150/PGPAmiga/AUTO/CLOSE/WAIT/SCREEN' || CFG.PUBSCREENNAME
  71. Call Pragma '*','STDOUT'
  72. Call Open 'STDIN','*'
  73.  
  74. if GLOBALDATA.PGPCommand = '' then 
  75. do
  76.     call getpath
  77.     pgpcommand = result
  78. end
  79. else pgpcommand = GLOBALDATA.PGPCOMMAND
  80.  
  81. address command pgpcommand filename ' -o' outfile  
  82. if(rc ~= 0) then
  83. do
  84.     REQUESTNOTIFY TEXT '"PGP failed. Check path or PGPPATH envirorment variable."' BT '"_Ok"'
  85.     exit
  86. end
  87.  
  88. SHOWTEXT outfile CURRENTMSGTEXT
  89. if(rc ~= 0) then 
  90. do 
  91.     REQUESTNOTIFY TEXT '"Not able to show the decrypted message."' BT '"_Ok"'
  92.     exit
  93. end
  94.  
  95.  
  96. address command 
  97. if exists(filename) then 'delete >nil:' filename
  98. if exists(outfile)  then 'delete >nil:' outfile
  99. exit 0
  100.  
  101.  
  102. getpath: procedure
  103. address command 'GetEnv >PIPE:PGPPATH PGPPATH'
  104. If rc = 0 Then
  105. Do
  106.     If Open('ppath','PIPE:PGPPATH','R') Then
  107.     Do
  108.         path = ReadLN('ppath')
  109.         If ~Close('ppath') Then Nop
  110.         path = path||'/PGP'
  111.         Return path
  112.     End
  113.     Else Return ""
  114. End
  115.